package com.vn.ld.btc.dao.common;

import java.io.Serializable;

/**
 * @author Shark{Loi.Do.Duy}
 */
public class SearchItem implements Serializable {

	private static final long serialVersionUID = 8390647963018466448L;

	private String key;
	private String expression;
	private Object value;
	private Object defaultValue;
	private boolean usingDefaultValue;
	private String logicOperator;
	private boolean enableNullSearch;

	public SearchItem() {
	}

	public SearchItem(String key, Object value) {
		super();
		this.key = key;
		this.value = value;
	}

	public SearchItem(String key, String expression, Object value) {
		super();
		this.key = key;
		this.expression = expression;
		this.value = value;
		this.logicOperator = FilterLogicOperator.AND.getQlString();
	}

	public SearchItem(String key, String expression, Object value, Boolean or) {
		super();
		this.key = key;
		this.expression = expression;
		this.value = value;
		this.logicOperator = FilterLogicOperator.OR.getQlString();
	}

	public SearchItem(String expression) {
		super();
		this.expression = expression;
		this.logicOperator = FilterLogicOperator.AND.getQlString();
	}

	public SearchItem(String expression, Boolean or) {
		super();
		this.expression = expression;
		this.logicOperator = FilterLogicOperator.OR.getQlString();
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getExpression() {
		return expression;
	}

	public void setExpression(String expression) {
		this.expression = expression;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public Object getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(Object defaultValue) {
		this.defaultValue = defaultValue;
	}

	public boolean isUsingDefaultValue() {
		return usingDefaultValue;
	}

	public void setUsingDefaultValue(boolean usingDefaultValue) {
		this.usingDefaultValue = usingDefaultValue;
	}

	public String getLogicOperator() {
		return logicOperator;
	}

	public void setLogicOperator(String logicOperator) {
		this.logicOperator = logicOperator;
	}

	public boolean isEnableNullSearch() {
		return enableNullSearch;
	}

	public void setEnableNullSearch(boolean enableNullSearch) {
		this.enableNullSearch = enableNullSearch;
	}

	public boolean isEmpty() {
		return value == null || (String.valueOf(value) == null || String.valueOf(value).trim().length() == 0);
	}
}
